<?php
use yii\db\Schema;
use yii\db\Migration;

/**
 * 文件存储表
 *
 * @author jois
 */
class m150828_054547_create_storages_table extends Migration
{

    public function up()
    {
        $this->createTable('storages', [
            'hash' => 'CHAR(32) NOT NULL PRIMARY KEY',
            'parent_hash' => Schema::TYPE_STRING . ' NOT NULL default \'\'',
            'filename' => Schema::TYPE_STRING . ' NOT NULL',
            'size' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0',
            'width' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0',
            'height' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0',
            'seconds' => 'decimal(12,3) NOT NULL DEFAULT \'0.000\'',
            'mime' => Schema::TYPE_STRING . ' NOT NULL default \'\'',
            'format' => Schema::TYPE_STRING . ' NOT NULL default \'\'',
            'path' => Schema::TYPE_STRING . ' NOT NULL default \'\'',
            'created_at' => Schema::TYPE_INTEGER . ' NOT NULL',
            'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL'
        ]);
    }

    public function down()
    {
        $this->dropTable('storages');
    }
}
